import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)
import i18n from '@/lang'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/** note: submenu only apppear when children.length>=1
**/

/**
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
**/
export const constantRouterMap = [
  { path: '/login', component: _import('platform/login/index') },
  { path: '/authredirect', component: _import('platform/login/authredirect') },
  { path: '/401', component: _import('platform/errorPage/401') },
  { path: '/home', component: _import('platform/layout/Layout'), redirect: '/index', name: 'home',
    children: [{
      path: '/index',
      name: 'homePage',
      component: _import(config.HOMEPAGE_PATH),
      meta: {
        icon: 'iconfont icon-home',
        name: 'mainPage',
        title: i18n.t('common.mainPage')
      }
    }]
  }
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

